<?php
require_once(dirname(dirname(__FILE__)).'/libs/db.class.php');
class Base{
    public $db;
    function __construct()
    {
        $this->db=new DB();
    }


    // 检测用户是否登录
    protected function is_login(){
        $token=getallheaders()['Token'];
        // 从token中解密用户信息
        $user=json_decode(base64_decode($token),true);
        $sql="select id,username from users where id={$user['id']}";
        $res=$this->db->get_one($sql);
        if(!empty($res)){
            return $res;
        }else{
            return false;
        }   
    }
}
?>